import pygame
import olpcgames
from olpcgames import activity
from sugar.graphics.toolbutton import ToolButton
from gettext import gettext as _

class MunchersActivity(activity.PyGameActivity):
    """It's Number Munchers, for the XO!"""
    
    game_name = 'run'
    game_title = _('XO Munchers')
    game_size = None

    def build_toolbar(self):
        """Build our Activity toolbar for the Sugar system."""
        toolbar = super(MunchersActivity,self).build_toolbar()
        
        # Add some toolbar buttons
        new = ToolButton('new') #Put the icon here, must be an svg in /icons 
        new.set_tooltip(_('New Game')) 
        new.connect('clicked', self._new_cb)
        toolbar.insert(new, 2)
        new.show()
    
        return toolbar

    def _new_cb(self, button):
        pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action='new'))
